<?php
/**
 * Notes:
 * User: wudg <544038230@qq.com>
 * Date: 2025/4/11 12:09
 */

namespace App\Utils;


class TimesUtil
{
    static function  friendlyTimestamp($timestamp) {
        $now = time();
        $diff = $now - $timestamp;

        if ($diff < 60) {
            return '刚刚';
        } elseif ($diff < 3600) {
            return floor($diff / 60) . '分钟前';
        } elseif ($diff < 86400) {
            return floor($diff / 3600) . '小时前';
        } elseif ($diff < 2592000) {
            return floor($diff / 86400) . '天前';
        } elseif ($diff < 31536000) {
            return floor($diff / 2592000) . '个月前';
        } else {
            return date("Y/m/d");
        }
    }
}